import Opt from '@/components/dt/info/Opt.js'

//bill
//billApproval
//billApprovalManager
//caseBillApproval

class Column extends Opt {

  constructor(name, tabName) {
    super()
    this.name = name
    this.tabName = tabName
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.auditName = {
      field: 'auditName',
      title: '审核人',
      visible: this.tabName == '1' || this.tabName == '2',
      minWidth: 100,
    }
    this.auditTime = {
      field: 'auditTime',
      title: '审核日期',
      visible: this.tabName == '1' || this.tabName == '2',
      minWidth: 120,
      cell: {
        text: {
          type: 'date'
        }
      }
    }
    this.auditReason = {
      field: 'auditReason',
      title: '驳回原因',
      visible: this.tabName == '2',
      minWidth: 140,
    }
    this.auditStateStr = {
      field: 'auditStateStr',
      title: '审批状态',
      visible: this.name == 'billApprovalManager',
      minWidth: 120,
    }
    this.nextChecker = {
      field: 'nextChecker',
      title: '当前审批节点',
      visible: this.name == 'billApprovalManager',
      minWidth: 140,
    }
    this.all = [{
        type: 'index',
        title: '序号',
        minWidth: 50,
      },
      {
        field: 'orgName',
        title: '所属组织',
        visible: this.name != 'caseBillApproval',
        minWidth: 130
      },
      {
        field: 'housesName',
        title: '案场名称',
        visible: this.name != 'caseBillApproval',
        minWidth: 130
      },
      {
        field: 'auditData.bonusName',
        title: '奖金单名称',
        minWidth: 130
      },
      {
        field: 'auditData.bonusType',
        title: '奖金单类型',
        minWidth: 110,
        cell: this.name == 'bill' ? {
          text: {
            type: 'dict',
            key: 'bonusType'
          }
        } : null
      },
      {
        field: 'auditData.settlementSumAmount',
        title: '可结算房源总销(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
      {
        field: 'auditData.sumAgentCost',
        title: '可结算代理费(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
      {
        field: 'auditData.bonusAmount',
        title: '奖金总额(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
      {
        field: 'auditData.bonusMonth',
        title: '奖金单月份',
        minWidth: 100,
      },
      {
        field: 'submitName',
        title: '提交人',
        minWidth: 100,
      },
      {
        field: 'submitTime',
        title: '提交日期',
        minWidth: 120,
        cell: {
          text: {
            type: 'date'
          }
        }
      },
      this.auditName,
      this.auditTime,
      this.auditReason,
      this.auditStateStr,
      this.nextChecker,
      {
        title: '操作',
        width: 180,
        fixed: 'right',
        cell: (item) => {
          if (this.name == 'billApproval' || this.name == 'caseBillApproval') {
            return {
              btn: [{
                title: '查看',
                event: 'onDetail'
              }, {
                title: '审批',
                code: this.name == 'billApproval' ? '0206050301' : '0109060100',
                visible: this.tabName == '0',
                event: 'onAudit'
              }]
            }
          } else if (this.name == 'billApprovalManager') {
            return {
              btn: [{
                title: '查看',
                event: 'onDetail'
              },{
                title: '流程信息',
                event: 'onFlow'
              }, {
                title: '下一步',
                code: '0206060101',
                event: 'onSkip',
                visible: item.isSkip == '0',
              }]
            }
          }
        }
      }
    ]
  }

}

export default Column
